package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.MovieBean;
import com.project.service.IMovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("movie")
public class MovieController {
    @Autowired
    private IMovieService movieService;

    @RequestMapping("findByItem")
    public IPage<MovieBean> findByItem(Integer pageNO, String name, String cinemaName, String time, Integer rowNum) {
        return movieService.findByItem(pageNO, name, cinemaName, time, rowNum);
    }

    @RequestMapping("buyMovie")
    public String buyMovie(MovieBean movie) {
        movieService.buyMovie(movie);
        return "ok";
    }


    @RequestMapping("findById/{movieId}")
    public MovieBean findById(@PathVariable("movieId") Integer movieId) {
        return movieService.findById(movieId);
    }
}
